# --------------------------------------------------------------------------------------------------------------------
# Project:             Digital Payment System (DPS)
# Website:             http://code.google.com/p/dps-x509/
# Purpose of document: Datastores for the roulette
# --------------------------------------------------------------------------------------------------------------------
from google.appengine.ext import db

# --------------------------------------------------------------------------------------------------------------------
class UserData(db.Model):
  """ Database entry for x509 certificate """
  user_                     = db.UserProperty()
  balance_                  = db.IntegerProperty() #amount of $$ invested in roulette
  userSelfSignedX509Base64_ = db.TextProperty()
  userCsrBase64_            = db.TextProperty()
  privateKey_               = db.TextProperty() #yes this is bad and definately violates the rule that the 
                                                #system should never know the private key. key is in str format of 
                                                #keyczar.keys.RSAPrivateKey format

# --------------------------------------------------------------------------------------------------------------------
class Transaction(db.Model):
  """ all transactions to and from the user """
  user_                     = db.ReferenceProperty(UserData) 
  tokenValue_               = db.IntegerProperty() #positive if is from bank, negative if to bank 
  date_                     = db.DateTimeProperty(auto_now_add=True)
  privateKey_               = db.TextProperty()
  x509TokenCertBase64_      = db.TextProperty()
  x509ReceiverCertBase64_   = db.TextProperty()
                                                
# --------------------------------------------------------------------------------------------------------------------
class RouletteHistory(db.Model):
  """ Store the last scores in the roulette wheel """
  values_                   = db.ListProperty(int)

  
  
